package heip.generator.main;

import heip.generator.entity.EntityTable;
import heip.generator.entity.TableClazz;
import heip.generator.generer.AbstractGenerator;
import heip.generator.template.TemplateProvider;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author aguu sunyanzi125@sohu.com
 * @Title:
 * @Description:
 * @date 2014/10/5 23:25
 */
public class EulerGenerator extends AbstractGenerator {

    /**模板信息*/
    private static String ENTITY_TEM = "TEMPLATE_EULER/ENTITY_TEMPLATE";
    private static String DAO_TEM = "TEMPLATE_EULER/DAO_TEMPLATE";



    public static void main(String[] args) throws Exception{
		EulerGenerator eg = new EulerGenerator();
		eg.execute();
		open();
    }

    /**
     *需要手动修改的变量 --------------------------------
     */
    public String moduleName = "grid";//模块
    public void execute() throws Exception{
		String[] tables = new String[]{
              //"tm_stock_outin_verify_relation"
                //"TM_TICKET",
				//"TM_OUTIN","TM_OUTIN_ERASE"
				// "TM_OUTIN_DETAIL","TM_OUTIN_ERASE_DETAIL"
				//"TM_STOCK","TM_STOCK_DETAIL",
			    //"TM_STOCK_OUTIN",
                //"TM_STOCK_VERIFY"
				//"TM_STOCK_VERIFY","TM_STOCK_INVALID"
				//"TM_VERIFY","TM_VERIFY_DETAIL","TM_VERIFY_INVALID",
				//"TM_TICKET_OUTIN_STAT",
				//"TM_TICKET_VERIFY_STAT"
                //"SYS_ORG"
                //"TM_TICKET_IN_STAT"
		        //"GRD_CASE"
                //"grd_grid","grd_facility"
                "fc_fee_standar","fc_fe"
        };

        //waterfee


		EntityTable[] entityTables = new EntityTable[tables.length];
		for(int i=0;i<tables.length;i++){
			entityTables[i]=new EntityTable(tables[i]);
		}

		generatorAll(entityTables);
	}

    public EulerGenerator(){
        gg.put("moduleName",moduleName);
    }


    /**
     * 生成PO
     * @param
     * @param tables
     * @throws Exception
     */
    public void generatorAll(EntityTable[] tables) throws Exception{
        for(EntityTable table: tables){
            String tableName= table.getTableName();
            generator.generateByTable(tableName,ENTITY_TEM);
            TableClazz tableClazz = new TableClazz(tableName);
            Map map = new HashMap();
            map.put("tableClazz",tableClazz);
            generator.generateByMap(map,DAO_TEM);
        }
    }


    public enum GenerationType{
        SEQUENCE,
        IDENTITY,
        AUTO,
        UUID
    }
}

